﻿using Abp;
using Abp.Castle.Logging.Log4Net;
using Abp.Dependency;
using Castle.Facilities.Logging;
using Microsoft.Owin.Hosting;
using MultipleDbContextEfCoreDemo.Services;
using System.Threading.Tasks;
namespace LawConsoleApp
{
    public class Program
    {
        static void Main(string[] args)
        {
            //using (var bootstrapper = AbpBootstrapper.Create<LawConsoleAppModule>())
            //{
            //    bootstrapper.IocManager.IocContainer
            //        .AddFacility<LoggingFacility>(
            //            f => f.UseAbpLog4Net().WithConfig("log4net.config")
            //        );

            //    bootstrapper.Initialize();

            //    using (var caller = bootstrapper.IocManager.ResolveAsDisposable<LawAppService>())
            //    {
            //       caller.Object.LawAddorUpdate();
            //    }
            //}

            try
            {
                using (var bootstrapper = AbpBootstrapper.Create<LawConsoleAppModule>())
                {
                    bootstrapper.IocManager.IocContainer
                        .AddFacility<LoggingFacility>(
                            f => f.UseAbpLog4Net().WithConfig("log4net.config")
                        );

                    bootstrapper.Initialize();

                    using (var caller = bootstrapper.IocManager.ResolveAsDisposable<LawAppService>())
                    {
                        //await caller.Object.DecipheringAsync();
                        caller.Object.LawAddorUpdate();
                    }
                }
            }
            catch (System.Exception ex)
            {
                throw ex;

            }

        }
    }
}
